package com.wc.FAKE;

import com.wc.Dao.EmpDao;
import com.wc.Dao.EmpDaoImpl;
import com.wc.domain.Dept;
import com.wc.domain.Emp;
import com.wc.emu.Role;
import com.wc.service.EmpService;
import com.wc.service.imple.EmpServiceImpl;
import com.wc.utils.Md5Util;
import com.wc.utils.RandomUtil;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName:DB
 * @Author: 鹿建文
 * @Date: 2022/3/21  - 14:28
 * @Describe:
 */
public class DB {

    private static EmpService empService = new EmpServiceImpl();

    public static List<Dept> depts = new ArrayList<>();
    public static List<Emp> emps = new ArrayList<>();
    static EmpDao empdao = new EmpDaoImpl();

    static {
        depts.add(new Dept(10, "sales", "chicago"));
        depts.add(new Dept(20, "reserch", "myhome"));


        String slat1 = RandomUtil.genString(5, RandomUtil.genInteger(8, 12));
        emps.add(Emp.builder()
                .empno(1001)
                .ename("张三")
                .job("clerk")
                .mgr(7788)
                .hiredate(LocalDate.now())
                .sal(new BigDecimal(888.8))
                .comm(new BigDecimal(77.7))
                .account("zhangsan")
                .password(Md5Util.encode("zhangsan", slat1))
                .salt(slat1)
                .deptno(10)
                .role(Role.COMMON).build());
        String slat2 = RandomUtil.genString(5, RandomUtil.genInteger(8, 12));
        emps.add(Emp.builder()
                .empno(1002)
                .ename("李四")
                .job("MANGER")
                .mgr(7788)
                .hiredate(LocalDate.now())
                .sal(new BigDecimal(888.8))
                .comm(new BigDecimal(77.7))
                .account("lisi")
                .password(Md5Util.encode("lisi", slat2))
                .salt(slat2)
                .role(Role.COMMON)
                .deptno(20)
                .build());

        String slat3 = RandomUtil.genString(5, RandomUtil.genInteger(8, 12));
        emps.add(Emp.builder()
                .empno(1003)
                .ename("王二")
                .job("clerk")
                .mgr(7788)
                .hiredate(LocalDate.now())
                .sal(new BigDecimal(888.8))
                .comm(new BigDecimal(77.7))
                .account("wanger")
                .password(Md5Util.encode("wanger", slat3))
                .salt(slat3)
                .role(Role.ADMIN)
                .deptno(20)
                .build());
    }


}
